<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link rel="STYLESHEET" href="lib.css" type='text/css' />
<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
<link rel='start' href='../index.html' title='Python documentation Index' />
<link rel="first" href="lib.html" title='Python library Reference' />
<link rel='contents' href='contents.html' title="Contents" />
<link rel='index' href='genindex.html' title='Index' />
<link rel='last' href='about.html' title='About this document...' />
<link rel='help' href='about.html' title='About this document...' />
<link rel="next" href="module-calendar.html" />
<link rel="prev" href="datatypes.html" />
<link rel="parent" href="datatypes.html" />
<link rel="next" href="node78.html" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='aesop' content='information' />
<title>5.1 datetime -- Basic date and time types</title>
</head>
<body>
<div class="navigation">
<div id='top-navigation-panel' xml:id='top-navigation-panel'>
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5. data Types"
  href="datatypes.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="5. data Types"
  href="datatypes.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="5.1.1 available Types"
  href="node78.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="datatypes.html">5. Data Types</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="datatypes.html">5. Data Types</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="node78.html">5.1.1 Available Types</a>
</div>
<hr /></div>
</div>
<!--End of Navigation Panel-->

<h1><a name="SECTION007100000000000000000">
5.1 <tt class="module">datetime</tt> --
         Basic date and time types</a>
</h1>

<p>
<a name="module-datetime"></a>

<p>

<span class="versionnote">New in version 2.3.</span>

<p>
The <tt class="module">datetime</tt> module supplies classes for manipulating dates
and times in both simple and complex ways.  While date and time
arithmetic is supported, the focus of the implementation is on
efficient member extraction for output formatting and manipulation.

<p>
There are two kinds of date and time objects: ``naive'' and ``aware''.
This distinction refers to whether the object has any notion of time
zone, daylight saving time, or other kind of algorithmic or political
time adjustment.  Whether a naive <tt class="class">datetime</tt> object represents
Coordinated Universal Time (UTC), local time, or time in some other
timezone is purely up to the program, just like it's up to the program
whether a particular number represents metres, miles, or mass.  Naive
<tt class="class">datetime</tt> objects are easy to understand and to work with, at
the cost of ignoring some aspects of reality.

<p>
For applications requiring more, <tt class="class">datetime</tt> and <tt class="class">time</tt>
objects have an optional time zone information member,
<tt class="member">tzinfo</tt>, that can contain an instance of a subclass of
the abstract <tt class="class">tzinfo</tt> class.  These <tt class="class">tzinfo</tt> objects
capture information about the offset from UTC time, the time zone
name, and whether Daylight Saving Time is in effect.  Note that no
concrete <tt class="class">tzinfo</tt> classes are supplied by the <tt class="module">datetime</tt>
module.  Supporting timezones at whatever level of detail is required
is up to the application.  The rules for time adjustment across the
world are more political than rational, and there is no standard
suitable for every application.

<p>
The <tt class="module">datetime</tt> module exports the following constants:

<p>
<dl><dt><b><tt id='l2h-603' xml:id='l2h-603'>MINYEAR</tt></b></dt>
<dd>
  The smallest year number allowed in a <tt class="class">date</tt> or
  <tt class="class">datetime</tt> object.  <tt class="constant">MINYEAR</tt>
  is <code>1</code>.
</dd></dl>

<p>
<dl><dt><b><tt id='l2h-604' xml:id='l2h-604'>MAXYEAR</tt></b></dt>
<dd>
  The largest year number allowed in a <tt class="class">date</tt> or <tt class="class">datetime</tt>
  object.  <tt class="constant">MAXYEAR</tt> is <code>9999</code>.
</dd></dl>

<p>
<div class="seealso">
  <p class="heading">See Also:</p>

  <dl compact="compact" class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-calendar.html">calendar</a></tt>:</b>
    <dd>General calendar related functions.
  </dl>
  <dl compact="compact" class="seemodule">
    <dt>Module <b><tt class="module"><a href="module-time.html">time</a></tt>:</b>
    <dd>Time access and conversions.
  </dl>
</div>

<p>

<p><br /></p><hr class='online-navigation' />
<div class='online-navigation'>
<!--Table of Child-Links-->
<a name="CHILD_LINKS"><strong>Subsections</strong></a>

<ul class="ChildLinks">
<li><a href="node78.html">5.1.1 Available Types</a>
<li><a href="datetime-timedelta.html">5.1.2 <tt class="class">timedelta</tt> Objects</a>
<li><a href="datetime-date.html">5.1.3 <tt class="class">date</tt> Objects</a>
<li><a href="datetime-datetime.html">5.1.4 <tt class="class">datetime</tt> Objects</a>
<li><a href="datetime-time.html">5.1.5 <tt class="class">time</tt> Objects</a>
<li><a href="datetime-tzinfo.html">5.1.6 <tt class="class">tzinfo</tt> Objects</a>
<li><a href="strftime-behavior.html">5.1.7 <tt class="method">strftime()</tt> Behavior</a>
</ul>
<!--End of Table of Child-Links-->
</div>

<div class="navigation">
<div class='online-navigation'>
<p></p><hr />
<table align="center" width="100%" cellpadding="0" cellspacing="2">
<tr>
<td class='online-navigation'><a rel="prev" title="5. data Types"
  href="datatypes.html"><img src='../icons/previous.png'
  border='0' height='32'  alt='Previous Page' width='32' /></a></td>
<td class='online-navigation'><a rel="parent" title="5. data Types"
  href="datatypes.html"><img src='../icons/up.png'
  border='0' height='32'  alt='Up one Level' width='32' /></a></td>
<td class='online-navigation'><a rel="next" title="5.1.1 available Types"
  href="node78.html"><img src='../icons/next.png'
  border='0' height='32'  alt='Next Page' width='32' /></a></td>
<td align="center" width="100%">Python Library Reference</td>
<td class='online-navigation'><a rel="contents" title="Table of Contents"
  href="contents.html"><img src='../icons/contents.png'
  border='0' height='32'  alt='Contents' width='32' /></a></td>
<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
  border='0' height='32'  alt='Module Index' width='32' /></a></td>
<td class='online-navigation'><a rel="index" title="Index"
  href="genindex.html"><img src='../icons/index.png'
  border='0' height='32'  alt='Index' width='32' /></a></td>
</tr></table>
<div class='online-navigation'>
<b class="navlabel">Previous:</b>
<a class="sectref" rel="prev" href="datatypes.html">5. Data Types</a>
<b class="navlabel">Up:</b>
<a class="sectref" rel="parent" href="datatypes.html">5. Data Types</a>
<b class="navlabel">Next:</b>
<a class="sectref" rel="next" href="node78.html">5.1.1 Available Types</a>
</div>
</div>
<hr />
<span class="release-info">Release 2.5.1, documentation updated on 18th April, 2007.</span>
</div>
<!--End of Navigation Panel-->
<address>
See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
</address>
</body>
</html>
